package com.design.adapter.print;

public class AdapterDemo {
    public static void main(String[] args) {
        // 创建 LegacyPrinter 对象
        LegacyPrinter legacyPrinter = new LegacyPrinter();
        // 创建 ModernPrinter 对象
        ModernPrinter modernPrinter = new ModernPrinter();

        // 使用 LegacyPrinter 原有的 print 方法
        legacyPrinter.print("Hello from Legacy Printer");

        // 使用适配器将 ModernPrinter 适配成 LegacyPrinter
        PrinterAdapter printerAdapter = new PrinterAdapter(modernPrinter);
        printerAdapter.print("Hello from Modern Printer (via Adapter)");
    }
}
